package cn.zhpdmmz.service.impl;

import cn.zhpdmmz.entity.Payment;
import cn.zhpdmmz.mapper.PaymentMapper;
import cn.zhpdmmz.service.IPaymentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Payment)表服务实现类
 *
 * @author ZHP
 * @since 2022-04-18 11:54:27
 */
@Service("paymentService")
public class PaymentServiceImpl implements IPaymentService {
    @Resource
    private PaymentMapper paymentMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param paymentId 主键
     * @return 实例对象
     */
    @Override
    public Payment queryById(Integer paymentId) {
        return this.paymentMapper.queryById(paymentId);
    }

    /**
     * 查询指定行
     *
     * @param payment 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Payment> queryAll(Payment payment) {
        return this.paymentMapper.queryAll(payment);
    }

    /**
     * 新增数据
     *
     * @param payment 实例对象
     * @return 实例对象
     */
    @Override
    public Payment insert(Payment payment) {
        this.paymentMapper.insert(payment);
        return payment;
    }

    /**
     * 修改数据
     *
     * @param payment 实例对象
     * @return 实例对象
     */
    @Override
    public Payment update(Payment payment) {
        this.paymentMapper.update(payment);
        return this.queryById(payment.getPaymentId());
    }

    /**
     * 通过主键删除数据
     *
     * @param paymentId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer paymentId) {
        return this.paymentMapper.deleteById(paymentId) > 0;
    }
}
